package com.lnlyj.alert;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

public class ActionView {

    private TextView rootView;
    private ActionCallback innerCallback;

    public interface ActionCallback {
        void onAction(View v);
    }

    ActionView(Activity context, String action, final ActionCallback callback) {
        rootView = (TextView) View.inflate(context, R.layout.layout_action, null);
        rootView.setText(action);
        rootView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (callback != null) {
                    callback.onAction(v);
                }
                if (innerCallback != null) {
                    innerCallback.onAction(v);
                }
            }
        });
    }

    public View getView() {
        return rootView;
    }

    public void setInnerCallback(ActionCallback innerCallback) {
        this.innerCallback = innerCallback;
    }
}
